package com.demo.spring.memory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.openai.OpenAiChatModel;

@Configuration
public class CommonConfig {

	@Autowired
	private OpenAiChatModel model;
	
	// 构建会话记忆体
	@Bean
	public ChatMemory chatMemory() {
		MessageWindowChatMemory memory = MessageWindowChatMemory.builder()
				.maxMessages(20)
				.build();
		return memory;
	}
	
}
